package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.biz.app.common.DataSetContrastFilerNumDto;
import com.sg.dto.biz.app.common.SpecCycleDto;
import com.sg.dto.biz.app.common.SpecExecCycleStageAnaDto;
import com.sg.dto.biz.app.common.TemplateCycleDto;
import com.sg.dto.biz.app.req.*;
import com.sg.dto.biz.app.res.*;
import com.sg.dto.integration.component.QuerySemanticEngineDetailReqDto;
import com.sg.dto.integration.component.QuerySemanticEngineDetailRespDto;
import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
import com.wicket.okrcomponent.integration.TemplateEngineService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.*;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbTargetCycle {

    @Resource
    private TemplateEngineService fwCompTemplateEngineClient;

    /**
     * code:receptionService
     * name:M3-获取接收字段（特殊方法）
     * desc:undefined
     * gen by moon at 8/29/2022, 12:45:03 PM
     **/
    @Trace(operationName = "M3-获取接收字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveFieldRespDto obtainReceiveField(ObtainReceiveFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveFieldRespDto.class);
    }

    /**
     * code:getPublicFieldCache
     * name:M3更新公共字段缓存
     * desc:undefined
     * gen by moon at 8/29/2022, 12:45:05 PM
     **/
    @Trace(operationName = "M3更新公共字段缓存")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public RefreshPublicFieldCacheRespDto refreshPublicFieldCache(RefreshPublicFieldCacheReqDto reqDto) {
        if (BaseInfoHolder.contextHolder.get() != null) {
            BaseInfoHolder.contextHolder.remove();
        }
        BaseInfoDO domain = new BaseInfoDO();
        domain.setSpecSpaceId(reqDto.getSpaceId());
        domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        domain.setSpecAppId(reqDto.getAppId());
        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new RefreshPublicFieldCacheRespDto();
    }

    /**
     * code:generateSemanticInstance
     * name:M3-生成语义内容
     * desc:undefined
     * gen by moon at 8/29/2022, 12:46:05 PM
     **/
    @Trace(operationName = "M3-生成语义内容")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public GenerateSemanticContentRespDto generateSemanticContent(GenerateSemanticContentReqDto reqDto) {
        //{cycleStandardName}{targetContentName}
        boolean bRetFlag = false;
        GenerateSemanticContentRespDto retData = new GenerateSemanticContentRespDto();
        String retConent = "";
        QuerySemanticEngineDetailReqDto querySemanticEngineDetailReqDto = new QuerySemanticEngineDetailReqDto();
        querySemanticEngineDetailReqDto.setTemplateSemanticEngineCode("GENERATE_TARGET_CYCLE_NAME");
        QuerySemanticEngineDetailRespDto querySemanticEngineDetailRespDto = fwCompTemplateEngineClient.querySemanticEngineDetail(querySemanticEngineDetailReqDto).getData();
        if (querySemanticEngineDetailRespDto != null && querySemanticEngineDetailRespDto.getTemplateEngineTemplate() != null) {
            String cycleStandardName = "\\{cycleStandardName}";
            String targetContentName = "\\{targetContentName}";
            if (reqDto.getCycleStandardName() != null && !reqDto.getCycleStandardName().isEmpty()
                    && reqDto.getTargetContentName() != null && !reqDto.getTargetContentName().isEmpty()) {
                bRetFlag = true;
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(cycleStandardName, reqDto.getCycleStandardName());
                retConent = retConent.replaceAll(targetContentName, reqDto.getTargetContentName());
            } else {
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(cycleStandardName, "---");
            }

            if (retConent != null && !retConent.isEmpty()) {
                retConent = retConent.replaceAll("---", "");
                retConent = retConent.replaceAll("（）", "");
                retData.setObjectName(retConent);
            }

            if (bRetFlag) {
                return retData;
            }

        }
        return retData;
    }

    /**
     * code:sumOfMultipleNum
     * name:M3计算数据集权重求和(特殊方法）
     * desc:undefined
     * gen by moon at 8/29/2022, 12:46:17 PM
     **/
    @Trace(operationName = "M3计算数据集权重求和(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateDataSetWeightSummationRespDto calculateDataSetWeightSummation(CalculateDataSetWeightSummationReqDto reqDto) {
        return new CalculateDataSetWeightSummationRespDto();
    }

    /**
     * code:sumOfMultipleNum
     * name:M3计算数据集分值求和(特殊方法）
     * desc:undefined
     * gen by moon at 8/29/2022, 12:46:18 PM
     **/
    @Trace(operationName = "M3计算数据集分值求和(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateDataSetScoreSummationRespDto calculateDataSetScoreSummation(CalculateDataSetScoreSummationReqDto reqDto) {
        return new CalculateDataSetScoreSummationRespDto();
    }

    /**
     * code:collectionsAggregation
     * name:M3数据集聚合上级被评对象目标周期
     * desc:undefined
     * gen by moon at 8/29/2022, 12:47:20 PM
     **/
    @Trace(operationName = "M3数据集聚合上级被评对象目标周期")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public AddEvaObjTargetCycleCollAggregationRespDto addEvaObjTargetCycleCollAggregation(AddEvaObjTargetCycleCollAggregationReqDto reqDto) {
        // TODO ruizhe skai dong ; 8/29/2022, 12:47:20 PM
        //有变化需要重新生成壳
        return new AddEvaObjTargetCycleCollAggregationRespDto();
    }

    /**
     * code:receptionService
     * name:M3获取接收被评对象目标周期权重字段（特殊方法）
     * desc:undefined
     * gen by moon at 8/29/2022, 12:47:39 PM
     **/
    @Trace(operationName = "M3获取接收被评对象目标周期权重字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveEvaObjTargetCycleFieldRespDto obtainReceiveEvaObjTargetCycleField(ObtainReceiveEvaObjTargetCycleFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveEvaObjTargetCycleFieldRespDto.class);
    }

    /**
     * code:getLastFromDataList
     * name:M3-取排序列表中上一条数据（特殊方法）
     * desc:undefined
     * gen by moon at 9/6/2022, 10:08:18 PM
     **/
    @Trace(operationName = "M3-取排序列表中上一条数据（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainGetLastFromDataListRespDto obtainGetLastFromDataList(ObtainGetLastFromDataListReqDto reqDto) {
        ObtainGetLastFromDataListRespDto retData = new ObtainGetLastFromDataListRespDto();
        EvaObjTargetCycleReportSortDto lastData = new EvaObjTargetCycleReportSortDto();
        for (EvaObjTargetCycleReportSortDto oneData : reqDto.getEvaObjTargetCycleReportSortList()) {
            if (oneData.getEvaObjTargetCycleId().equals(reqDto.getEvaObjTargetCycleId())) {
                retData.setLastEvaObjTargetCycleId(lastData.getEvaObjTargetCycleId());
                break;
            }
            lastData = oneData;
        }
        return retData;
    }

    /**
     * code:rowToColumn
     * name:M3-转换被评对象目标周期数据行转列（特殊方法）
     * desc:undefined
     * gen by moon at 9/6/2022, 10:09:06 PM
     **/
    @Trace(operationName = "M3-转换被评对象目标周期数据行转列（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public AddStandardDataColumnToRowRespDto addStandardDataColumnToRow(AddStandardDataColumnToRowReqDto reqDto) {
        AddStandardDataColumnToRowRespDto retData = new AddStandardDataColumnToRowRespDto();
        retData.getEvaObjTargetCycleList().add(reqDto.getDepObjMisEvaObjTargetCycleId());
        retData.getEvaObjTargetCycleList().add(reqDto.getOkrDepEvaObjTargetCycleId());
        retData.getEvaObjTargetCycleList().add(reqDto.getOkrPerEvaObjTargetCycleId());
        return retData;
    }

    /**
     * code:objectToData
     * name:M执行图片多条转数据集
     * desc:undefined
     * gen by moon at 9/7/2022, 1:13:48 AM
     **/
    @Trace(operationName = "M执行图片多条转数据集")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementPicMultipleSetDataEntryRespDto implementPicMultipleSetDataEntry(ImplementPicMultipleSetDataEntryReqDto reqDto) {
        ImplementPicMultipleSetDataEntryRespDto retData = new ImplementPicMultipleSetDataEntryRespDto();
        if (reqDto.getPicMultipleSetDataEntryList() == null || reqDto.getPicMultipleSetDataEntryList().size() <= 0) {
            return retData;
        }
        for (PicMultipleSetDataEntryDto oneSrc : reqDto.getPicMultipleSetDataEntryList()) {
            if (oneSrc.getDatasetField() != null && !oneSrc.getDatasetField().isEmpty()) {
                String[] fileListSplit = oneSrc.getDatasetField().split(",");
                if (fileListSplit != null && fileListSplit.length > 0) {
                    for (String oneFile : fileListSplit) {
                        if (oneFile.equals("--")) {
                            continue;
                        }
                        PicMultipleSetDataEntryDto elm = new PicMultipleSetDataEntryDto();
                        elm.setCycleStageDataId(oneSrc.getCycleStageDataId());
                        elm.setDatasetPrimarykey(CommonFunctionHelper.getFilePath(oneFile));
                        retData.getPicMultipleSetDataEntryList().add(elm);
                    }
                }
            }
        }
        return retData;
    }

    /**
     * code:getDataCount
     * name:M3-数据集计算完成数量（特殊方法）
     * desc:undefined
     * gen by moon at 9/13/2022, 3:00:17 AM
     **/
    @Trace(operationName = "M3-数据集计算完成数量（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public QueryDataSetCountQuantityAccomplishDetailRespDto queryDataSetCountQuantityAccomplishDetail(QueryDataSetCountQuantityAccomplishDetailReqDto reqDto) {
        // TODO ruizhe skai dong ; 9/13/2022, 3:00:17 AM
        return new QueryDataSetCountQuantityAccomplishDetailRespDto();
    }

    /**
     * code:publicFieldCache
     * name:M3执行业务应用公共字段推送内存（特殊方法）
     * desc:undefined
     * gen by moon at 9/13/2022, 5:55:18 PM
     **/
    @Trace(operationName = "M3执行业务应用公共字段推送内存（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {
        BaseInfoDO domain = new BaseInfoDO();
        if (BaseInfoHolder.contextHolder.get() != null) {
            BeanUtil.copyProperties(BaseInfoHolder.contextHolder.get().getBaseInfo(), domain);
            BaseInfoHolder.contextHolder.remove();
        }
        if (reqDto.getSpaceId() != null) {
            domain.setSpecSpaceId(reqDto.getSpaceId());
        }

        if (reqDto.getCreateInductionId() != null) {
            domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        }

        if (reqDto.getAppId() != null) {
            domain.setSpecAppId(reqDto.getAppId());
        }

        if (reqDto.getHighestOrgID() != null) {
            domain.setSpecHighestOrgID(reqDto.getHighestOrgID());
        }

        if (reqDto.getUserId() != null) {
            domain.setSpecUserId(reqDto.getUserId());
        }

        if (reqDto.getOriginalRoleMemberId() != null) {
            domain.setSpecOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());
        }

        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new ImplementBizPublicFieldPushMemoryRespDto();
    }

    /**
     * code:receptionService
     * name:M3获取数据集字段(特殊方法）
     * desc:undefined
     * gen by moon at 9/18/2022, 8:25:47 PM
     **/
    @Trace(operationName = "M3获取数据集字段(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainDataSetFieldsRespDto obtainDataSetFields(ObtainDataSetFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainDataSetFieldsRespDto.class);
    }

    /**
     * code:compareTheDatasetWithASingleField
     * name:M3数据集对比单字段数值相同（特殊方法）
     * desc:undefined
     * gen by moon at 9/18/2022, 8:25:57 PM
     **/
    @Trace(operationName = "M3数据集对比单字段数值相同（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public QueryDataSetContrastFilerNumEquivalenceDetailRespDto queryDataSetContrastFilerNumEquivalenceDetail(QueryDataSetContrastFilerNumEquivalenceDetailReqDto reqDto) {
        QueryDataSetContrastFilerNumEquivalenceDetailRespDto retData = new QueryDataSetContrastFilerNumEquivalenceDetailRespDto();
        Map<Double, DataSetContrastFilerNumDto> indexInfo = new HashMap<>();
        for (DataSetContrastFilerNumDto one : reqDto.getDataSetContrastFilerNumList()) {
            indexInfo.put(one.getTargetValue(), one);
        }
        if (indexInfo.size() == 1) {
            retData.setIsSame("TRUE");
        } else {
            retData.setIsSame("FALSE");
        }
        return retData;
    }

    /**
     * code:sumOfMultipleNum
     * name:M3数据集求和(特殊方法）
     * desc:undefined
     * gen by moon at 9/18/2022, 8:26:07 PM
     **/
    @Trace(operationName = "M3数据集求和(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public UpdateSumOfMultipleNumRespDto updateSumOfMultipleNum(UpdateSumOfMultipleNumReqDto reqDto) {
        UpdateSumOfMultipleNumRespDto retData = new UpdateSumOfMultipleNumRespDto();
        Double sum = 0D;
        for (SumOfMultipleNumDto one : reqDto.getSumOfMultipleNumList()) {
            sum = sum + one.getTargetValue();
        }
        retData.setCalcResult(sum);
        return retData;
    }

    /**
     * code:numericalSizeComparison
     * name:M3两数值对比大小（特殊方法）
     * desc:undefined
     * gen by moon at 9/18/2022, 8:26:13 PM
     **/
    @Trace(operationName = "M3两数值对比大小（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public QueryNumericalContrastMagnitudeDetailRespDto queryNumericalContrastMagnitudeDetail(QueryNumericalContrastMagnitudeDetailReqDto reqDto) {
        QueryNumericalContrastMagnitudeDetailRespDto retData = new QueryNumericalContrastMagnitudeDetailRespDto();
        if (reqDto.getCalcPara1() < reqDto.getCalcPara2()) {
            retData.setNumCompareResult("BEFORE");
        } else if (reqDto.getCalcPara1() > reqDto.getCalcPara2()) {
            retData.setNumCompareResult("LATER");
        } else if (reqDto.getCalcPara1() == reqDto.getCalcPara2()) {
            retData.setNumCompareResult("PRESENT");
        }
        return retData;
    }

    /**
     * code:receptionService
     * name:M3获取接收外部字段(特殊方法）
     * desc:undefined
     * gen by moon at 9/21/2022, 5:01:41 PM
     **/
    @Trace(operationName = "M3获取接收外部字段(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveOutFieldRespDto obtainReceiveOutField(ObtainReceiveOutFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveOutFieldRespDto.class);
    }

    /**
     * code:collectionsAggregation
     * name:M3-周期列表第一步融合（周期+周期类型+是否末级周期+周期类型配置标识+最近可循环周期类型）
     * desc:undefined
     * gen by moon at 9/24/2022, 10:07:47 PM
     **/
    @Trace(operationName = "M3-周期列表第一步融合（周期+周期类型+是否末级周期+周期类型配置标识+最近可循环周期类型）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementCycleStepOneCollectionsAggregationRespDto implementCycleStepOneCollectionsAggregation(ImplementCycleStepOneCollectionsAggregationReqDto reqDto) {
        ImplementCycleStepOneCollectionsAggregationRespDto retData = new ImplementCycleStepOneCollectionsAggregationRespDto();
        for (CycleDto oneCycle : reqDto.getCycleList()) {
            CycleDto elm = BeanUtil.toBean(oneCycle, CycleDto.class);
            for (CycleTypeDto oneCycleType : reqDto.getCycleTypeList()) {
                if (oneCycleType.getCycleTypeCode().equals(oneCycle.getCycleTypeCode())) {
                    elm.setIsLastCycle(oneCycleType.getIsLastCycle());
                    elm.setCycleTypeConfCode(oneCycleType.getCycleTypeConfCode());
                    elm.setNextCyclePeriod(oneCycleType.getNextCyclePeriod());
                }
            }
            retData.getCycleList().add(elm);
        }
        return retData;
    }

    /**
     * code:collectionsAggregation
     * name:M3-周期列表第二步融合（融合是否当前周期+是否下一周期）
     * desc:undefined
     * gen by moon at 9/24/2022, 10:07:55 PM
     **/
    @Trace(operationName = "M3-周期列表第二步融合（融合是否当前周期+是否下一周期）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementCycleStepTwoCollectionsAggregationRespDto implementCycleStepTwoCollectionsAggregation(ImplementCycleStepTwoCollectionsAggregationReqDto reqDto) {
        ImplementCycleStepTwoCollectionsAggregationRespDto retData = new ImplementCycleStepTwoCollectionsAggregationRespDto();
        for (CycleDto oneCycle : reqDto.getCycleList()) {
            oneCycle.setIsCurrentCycle("FALSE");
            oneCycle.setIsNextCycle("FALSE");
        }
        for (CycleDto oneCycle : reqDto.getCycleList()) {
            CycleDto elm = new CycleDto();
            BeanUtil.copyProperties(oneCycle, elm);
            if (oneCycle.getCycleId().equals(reqDto.getCurrentCycleId())) {
                elm.setIsCurrentCycle("TRUE");
                elm.setIsNextCycle("FALSE");
            }
            if (oneCycle.getCycleId().equals(reqDto.getNextCycleId())) {
                elm.setIsCurrentCycle("FALSE");
                elm.setIsNextCycle("TRUE");
            }
            if (oneCycle.getCycleId().equals(reqDto.getCurrentSubCycleId())) {
                elm.setIsCurrentCycle("TRUE");
                elm.setIsNextCycle("FALSE");
            }
            if (oneCycle.getCycleId().equals(reqDto.getNextSubCycleId())) {
                elm.setIsCurrentCycle("FALSE");
                elm.setIsNextCycle("TRUE");
            }
            retData.getCycleList().add(elm);
        }
        return retData;
    }

    /**
     * code:getCollectionsDiff
     * name:M3-被评对象目标周期数据集取差集(特殊方法）
     * desc:undefined
     * gen by moon at 9/27/2022, 8:38:18 AM
     **/
    @Trace(operationName = "M3-被评对象目标周期数据集取差集(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public GenerateEvaObjTargetCycleExtendDifferenceRespDto generateEvaObjTargetCycleExtendDifference(GenerateEvaObjTargetCycleExtendDifferenceReqDto reqDto) {
        // TODO ruizhe skai dong ; 9/27/2022, 8:38:18 AM
        return new GenerateEvaObjTargetCycleExtendDifferenceRespDto();
    }

    /**
     * code:additionOfTwoNum
     * name:M3-计算两个数值相加(特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:08:34 AM
     **/
    @Trace(operationName = "M3-计算两个数值相加(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateAddOfTwoNumRespDto calculateAddOfTwoNum(CalculateAddOfTwoNumReqDto reqDto) {
        // TODO ruizhe skai dong ; 9/29/2022, 7:08:34 AM
        return new CalculateAddOfTwoNumRespDto();
    }

    /**
     * code:subtractionOfTwoNum
     * name:M3-计算两个数值相减(特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:08:34 AM
     **/
    @Trace(operationName = "M3-计算两个数值相减(特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateSubtractOfTwoNumRespDto calculateSubtractOfTwoNum(CalculateSubtractOfTwoNumReqDto reqDto) {
        // TODO ruizhe skai dong ; 9/29/2022, 7:08:34 AM
        return new CalculateSubtractOfTwoNumRespDto();
    }

    /**
     * code:sumOfColsCopWithFat
     * name:M3-判断子周期列表相加与父周期比较（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:03 AM
     **/
    @Trace(operationName = "M3-判断子周期列表相加与父周期比较（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeSumOfColsCopWithFatRespDto judgeSumOfColsCopWithFat(JudgeSumOfColsCopWithFatReqDto reqDto) {
        JudgeSumOfColsCopWithFatRespDto retData = new JudgeSumOfColsCopWithFatRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;
        TargetCycleTargeValuetDto fatherCycle = null;
        //查找父周期
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsParentCycle().equals("TRUE")) {
                fatherCycle = oneCycle;
                break;
            }
        }
        if (fatherCycle == null) {
            return retData;
        }

        // TODO: 2022/12/2 左右改过
        if (ObjectUtils.isNotEmpty(fatherCycle.getTargetDiagnosticValue())) {
            targetRight = fatherCycle.getTargetDiagnosticValue();
            //子周期求和
            for (TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()) {
                if (subOne.getIsSubCycle().equals("TRUE")) {
                    targetLeft = targetLeft + subOne.getTargetDiagnosticValue();
                }
            }
        } else if (ObjectUtils.isNotEmpty(fatherCycle.getTargetValue())) {
            targetRight = fatherCycle.getTargetValue();
            //子周期求和
            for (TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()) {
                if (subOne.getIsSubCycle().equals("TRUE")) {
                    targetLeft = targetLeft + subOne.getTargetValue();
                }
            }
        } else {
            return retData;
        }

        //     * 运算符号 GREATER_THAN:大于 LESS_THAN:小于 EQUAL:等于 GREATER_EQUAL_THAN:大于等于 LESS_EQUAL_THAN:小于等于 ALL_NOT_EQUAL:均不低于 ALL_NOT_GREATER:均不高于
        if (reqDto.getLogicalOperator().equals("GREATER_THAN")) {
            if (targetLeft.doubleValue() > targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_THAN")) {
            if (targetLeft.doubleValue() < targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("EQUAL")) {
            if (targetLeft.doubleValue() == targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("GREATER_EQUAL_THAN")) {
            if (targetLeft.doubleValue() >= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_EQUAL_THAN")) {
            if (targetLeft.doubleValue() <= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_EQUAL")) {
            //这个壳没有
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_GREATER")) {
            //这个壳没有
        }
        return retData;
    }

    /**
     * code:colsEqualWithFat
     * name:M3-判断子周期列表是否与父周期相等（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:04 AM
     **/
    @Trace(operationName = "M3-判断子周期列表是否与父周期相等（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeColsEqualWithFatRespDto judgeColsEqualWithFat(JudgeColsEqualWithFatReqDto reqDto) {
        JudgeColsEqualWithFatRespDto retData = new JudgeColsEqualWithFatRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;
        TargetCycleTargeValuetDto fatherCycle = null;
        //查找父周期
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsParentCycle().equals("TRUE")) {
                fatherCycle = oneCycle;
                break;
            }
        }
        if (fatherCycle == null) {
            return retData;
        }

        if (ObjectUtils.isNotEmpty(fatherCycle.getTargetDiagnosticValue())) {
            targetLeft = fatherCycle.getTargetDiagnosticValue();
        } else if (ObjectUtils.isNotEmpty(fatherCycle.getTargetValue())) {
            targetLeft = fatherCycle.getTargetValue();
        } else {
            return retData;
        }

        //子周期求和
//         for(TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()){
//             if(subOne.getIsSubCycle().equals("TRUE")){
//                 targetRight = targetRight + subOne.getTargetDiagnosticValue();
//             }
//         }
        //     * 运算符号 GREATER_THAN:大于 LESS_THAN:小于 EQUAL:等于 GREATER_EQUAL_THAN:大于等于 LESS_EQUAL_THAN:小于等于 ALL_NOT_EQUAL:均不低于 ALL_NOT_GREATER:均不高于
        if (reqDto.getLogicalOperator().equals("GREATER_THAN")) {
            //这个壳不存在
        } else if (reqDto.getLogicalOperator().equals("LESS_THAN")) {
            //这个壳不存在
        } else if (reqDto.getLogicalOperator().equals("EQUAL")) {
            for (TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()) {
                if (ObjectUtils.isNotEmpty(subOne.getTargetDiagnosticValue())) {
                    if (subOne.getTargetDiagnosticValue().doubleValue() == targetLeft.doubleValue()) {
                        retData.setOutputNum(1L);
                        continue;
                    } else {
                        retData.setOutputNum(0L);
                        break;
                    }
                } else {
                    if (subOne.getTargetValue().doubleValue() == targetLeft.doubleValue()) {
                        retData.setOutputNum(1L);
                        continue;
                    } else {
                        retData.setOutputNum(0L);
                        break;
                    }
                }

            }
        } else if (reqDto.getLogicalOperator().equals("GREATER_EQUAL_THAN")) {
            //这个壳不存在
        } else if (reqDto.getLogicalOperator().equals("LESS_EQUAL_THAN")) {
            //这个壳不存在
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_EQUAL")) {
            //这个壳没有
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_GREATER")) {
            //这个壳没有
        }
        return retData;
    }

    /**
     * code:lastOfColsCopWithFat
     * name:M3-判断子周期列表中最晚与父周期比较（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:04 AM
     **/
    @Trace(operationName = "M3-判断子周期列表中最晚与父周期比较（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeLastOfColsCopWithFatRespDto judgeLastOfColsCopWithFat(JudgeLastOfColsCopWithFatReqDto reqDto) {
        JudgeLastOfColsCopWithFatRespDto retData = new JudgeLastOfColsCopWithFatRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;
        TargetCycleTargeValuetDto fatherCycle = null;
        //查找父周期
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsParentCycle().equals("TRUE")) {
                fatherCycle = oneCycle;
                break;
            }
        }
        if (fatherCycle == null) {
            return retData;
        }

        // TODO: 2022/12/2 左右改过
        if (ObjectUtils.isNotEmpty(fatherCycle.getTargetDiagnosticValue())) {
            targetRight = fatherCycle.getTargetDiagnosticValue();
        } else if (ObjectUtils.isNotEmpty(fatherCycle.getTargetValue())) {
            targetRight = fatherCycle.getTargetValue();
        } else {
            return retData;
        }


        //找最晚子周期

        List<TargetCycleTargeValuetDto> subFiltredList = new ArrayList<>();
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsSubCycle().equals("TRUE")) {
                subFiltredList.add(oneCycle);
            }
        }

        TargetCycleTargeValuetDto lastOne = null;
        if (CollectionUtil.isNotEmpty(subFiltredList)) {
            lastOne = subFiltredList.get(subFiltredList.size() - 1);
        } else {
            return retData;
        }


        if (ObjectUtils.isNotEmpty(fatherCycle.getTargetDiagnosticValue())) {
            targetLeft = lastOne.getTargetDiagnosticValue();
        } else {
            targetLeft = lastOne.getTargetValue();
        }

        //     * 运算符号 GREATER_THAN:大于 LESS_THAN:小于 EQUAL:等于 GREATER_EQUAL_THAN:大于等于 LESS_EQUAL_THAN:小于等于 ALL_NOT_EQUAL:均不低于 ALL_NOT_GREATER:均不高于
        if (reqDto.getLogicalOperator().equals("GREATER_THAN")) {
            if (targetLeft.doubleValue() > targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_THAN")) {
            if (targetLeft.doubleValue() < targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("EQUAL")) {
            if (targetLeft.doubleValue() == targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("GREATER_EQUAL_THAN")) {
            if (targetLeft.doubleValue() >= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_EQUAL_THAN")) {
            if (targetLeft.doubleValue() <= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_EQUAL")) {
            //这个壳没有
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_GREATER")) {
            //这个壳没有
        }
        return retData;
    }

    /**
     * code:twoOfColsCop
     * name:M3-判断子周期列表中两个数比较（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:05 AM
     **/
    @Trace(operationName = "M3-判断子周期列表中两个数比较（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeTwoOfcolsCopRespDto judgeTwoOfcolsCop(JudgeTwoOfcolsCopReqDto reqDto) {
        JudgeTwoOfcolsCopRespDto retData = new JudgeTwoOfcolsCopRespDto();
        retData.setOutputNum(1L);
        for (int i = reqDto.getTargetCycleTargeValuetList().size() - 1; i > 0; i--) {
            TargetCycleTargeValuetDto after = reqDto.getTargetCycleTargeValuetList().get(i);
            TargetCycleTargeValuetDto before = reqDto.getTargetCycleTargeValuetList().get(i - 1);
            if (after.getTargetValue() == null || before.getTargetValue() == null) {
                return retData;
            }
            if (after.getTargetValue() < before.getTargetValue()) {
                retData.setOutputNum(0L);
                break;
            }
        }
        return retData;
    }

    /**
     * code:sumOfColsCopWithMid
     * name:M3-判断子周期列表相加与中周期比较（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:07 AM
     **/
    @Trace(operationName = "M3-判断子周期列表相加与中周期比较（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeSumOfColsCopWithMidRespDto judgeSumOfColsCopWithMid(JudgeSumOfColsCopWithMidReqDto reqDto) {
        JudgeSumOfColsCopWithMidRespDto retData = new JudgeSumOfColsCopWithMidRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;

        TargetCycleTargeValuetDto midCycle = null;
        for (TargetCycleTargeValuetDto one : reqDto.getTargetCycleTargeValuetList()) {
            if (one.getIsMetaphase().equals("TRUE")) {
                midCycle = one;
                if (ObjectUtils.isNotEmpty(one.getTargetDiagnosticValue())) {
                    targetRight = one.getTargetDiagnosticValue();
                } else if (ObjectUtils.isNotEmpty(one.getTargetValue())) {
                    targetRight = one.getTargetValue();
                } else {
                    return retData;
                }
            }
        }

        if (midCycle == null) {
            return retData;
        }

        List<TargetCycleTargeValuetDto> subCycleList = new ArrayList<>();

        for (TargetCycleTargeValuetDto one : reqDto.getTargetCycleTargeValuetList()) {
            if (one.getIsSubCycle().equals("TRUE") && one.getOrderNumber() >= midCycle.getOrderNumber()) {
                subCycleList.add(one);
            }
        }

        for (TargetCycleTargeValuetDto one : subCycleList) {
            if (ObjectUtils.isNotEmpty(one.getTargetDiagnosticValue())) {
                targetLeft = targetLeft + one.getTargetDiagnosticValue();
            } else {
                targetLeft = targetLeft + one.getTargetValue();
            }
        }

        //     * 运算符号 GREATER_THAN:大于 LESS_THAN:小于 EQUAL:等于 GREATER_EQUAL_THAN:大于等于 LESS_EQUAL_THAN:小于等于 ALL_NOT_EQUAL:均不低于 ALL_NOT_GREATER:均不高于
        if (reqDto.getLogicalOperator().equals("GREATER_THAN")) {
            if (targetLeft.doubleValue() > targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_THAN")) {
            if (targetLeft.doubleValue() < targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("EQUAL")) {
            if (targetLeft.doubleValue() == targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("GREATER_EQUAL_THAN")) {
            if (targetLeft.doubleValue() >= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_EQUAL_THAN")) {
            if (targetLeft.doubleValue() <= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_EQUAL")) {
            //这个壳没有
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_GREATER")) {
            //这个壳没有
        }
        return retData;
    }

    /**
     * code:colsEqualWithMid
     * name:M3-判断子周期列表是否与中期相等（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:07 AM
     **/
    @Trace(operationName = "M3-判断子周期列表是否与中期相等（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeColsEqualWithMidRespDto judgeColsEqualWithMid(JudgeColsEqualWithMidReqDto reqDto) {
        JudgeColsEqualWithMidRespDto retData = new JudgeColsEqualWithMidRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;
        List<TargetCycleTargeValuetDto> subList = null;

        //查找中期
        TargetCycleTargeValuetDto midCycle = null;
        for (TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()) {
            if (subOne.getIsMetaphase().equals("TRUE")) {
                midCycle = subOne;
                break;
            }
        }

        //查找自周期列表
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsSubCycle().equals("TRUE") && oneCycle.getOrderNumber() >= midCycle.getOrderNumber()) {
                subList.add(oneCycle);
            }
        }


        if (ObjectUtils.isEmpty(midCycle)) {
            return retData;
        }

        if (ObjectUtils.isNotEmpty(midCycle.getTargetDiagnosticValue())) {
            retData.setOutputNum(1L);
            for (TargetCycleTargeValuetDto oneSub : subList) {
                if (midCycle != null && oneSub.getTargetDiagnosticValue().doubleValue() != midCycle.getTargetDiagnosticValue().doubleValue()) {
                    retData.setOutputNum(0L);
                    break;
                }
            }
        } else if (ObjectUtils.isNotEmpty(midCycle.getTargetValue())) {
            retData.setOutputNum(1L);
            for (TargetCycleTargeValuetDto oneSub : subList) {
                if (midCycle != null && oneSub.getTargetValue().doubleValue() != midCycle.getTargetValue().doubleValue()) {
                    retData.setOutputNum(0L);
                    break;
                }
            }
        } else {
            return retData;
        }


        return retData;
    }

    /**
     * code:lastOfColsCopWithMid
     * name:M3-判断子周期列表中最晚与中期比较（特殊方法）
     * desc:undefined
     * gen by moon at 9/29/2022, 7:09:08 AM
     **/
    @Trace(operationName = "M3-判断子周期列表中最晚与中期比较（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public JudgeLastOfColsCopWithMidRespDto judgeLastOfColsCopWithMid(JudgeLastOfColsCopWithMidReqDto reqDto) {
        JudgeLastOfColsCopWithMidRespDto retData = new JudgeLastOfColsCopWithMidRespDto();
        Double targetLeft = 0D;
        Double targetRight = 0D;

        TargetCycleTargeValuetDto midCycle = null;
        //查找中期
        for (TargetCycleTargeValuetDto subOne : reqDto.getTargetCycleTargeValuetList()) {
            if (subOne.getIsMetaphase().equals("TRUE")) {
                midCycle = subOne;
                break;
            }
        }

        //查找最近子周期
        TargetCycleTargeValuetDto lastCycle = null;
        List<TargetCycleTargeValuetDto> filteredList = new ArrayList<>();
        for (TargetCycleTargeValuetDto oneCycle : reqDto.getTargetCycleTargeValuetList()) {
            if (oneCycle.getIsSubCycle().equals("TRUE") && oneCycle.getOrderNumber() >= midCycle.getOrderNumber()) {
                filteredList.add(oneCycle);
            }
        }

        lastCycle = filteredList.get(filteredList.size() - 1);


        if (ObjectUtils.isEmpty(lastCycle) || ObjectUtils.isEmpty(midCycle)) {
            return retData;
        }

        targetLeft = lastCycle.getTargetValue();
        targetRight = midCycle.getTargetValue();

        if (targetLeft == null || targetRight == null) {
            return retData;
        }

        //     * 运算符号 GREATER_THAN:大于 LESS_THAN:小于 EQUAL:等于 GREATER_EQUAL_THAN:大于等于 LESS_EQUAL_THAN:小于等于 ALL_NOT_EQUAL:均不低于 ALL_NOT_GREATER:均不高于
        if (reqDto.getLogicalOperator().equals("GREATER_THAN")) {
            if (targetLeft.doubleValue() > targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_THAN")) {
            if (targetLeft.doubleValue() < targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("EQUAL")) {
            if (targetLeft.doubleValue() == targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("GREATER_EQUAL_THAN")) {
            if (targetLeft.doubleValue() >= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("LESS_EQUAL_THAN")) {
            if (targetLeft.doubleValue() <= targetRight.doubleValue()) {
                retData.setOutputNum(1L);
            } else {
                retData.setOutputNum(0L);
            }
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_EQUAL")) {
            //这个壳没有
        } else if (reqDto.getLogicalOperator().equals("ALL_NOT_GREATER")) {
            //这个壳没有
        }

        return retData;
    }

    /**
     * code:getLastListFromDataList
     * name:M3-查询中期之前的所有子周期列表
     * desc:undefined
     * gen by moon at 10/7/2022, 6:05:14 PM
     **/
    @Trace(operationName = "M3-查询中期之前的所有子周期列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainGetLastListFromDataListRespDto obtainGetLastListFromDataList(ObtainGetLastListFromDataListReqDto reqDto) {
        ObtainGetLastListFromDataListRespDto retData = new ObtainGetLastListFromDataListRespDto();
        List<EvaObjTargetCycleReportSortDto> filteredList = new ArrayList<EvaObjTargetCycleReportSortDto>();
        for (EvaObjTargetCycleReportSortDto one : reqDto.getEvaObjTargetCycleReportSortList()) {
            filteredList.add(one);
            if (one.getEvaObjTargetCycleId().equals(reqDto.getEvaObjTargetCycleId())) {
                retData.setEvaObjTargetCycleReportSortList(filteredList);
                return retData;
            }
        }
        return retData;
    }

    /**
     * code:receptionService
     * name:3-2-05查询评价对象ID
     * desc:undefined
     * gen by moon at 10/8/2022, 1:17:34 AM
     **/
    @Trace(operationName = "3-2-05查询评价对象ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public QueryEvaObjectDetailRespDto queryEvaObjectDetail(QueryEvaObjectDetailReqDto reqDto) {
        return BeanUtil.toBean(reqDto, QueryEvaObjectDetailRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3执行业务应用构造出入参字段（特殊方法）
     * desc:undefined
     * gen by moon at 10/8/2022, 11:41:02 PM
     **/
    @Trace(operationName = "M3执行业务应用构造出入参字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizConstructAccessParameterFieldRespDto implementBizConstructAccessParameterField(ImplementBizConstructAccessParameterFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementBizConstructAccessParameterFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3-执行【循环结束】
     * desc:undefined
     * gen by moon at 10/8/2022, 11:41:08 PM
     **/
    @Trace(operationName = "M3-执行【循环结束】")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementEndCycleRespDto implementEndCycle(ImplementEndCycleReqDto reqDto) {
        // TODO ruizhe skai dong ; 10/8/2022, 11:41:08 PM
        return new ImplementEndCycleRespDto();
    }

    /**
     * code:generateSemanticInstance
     * name:M3-生成语义内容
     * desc:undefined
     * gen by moon at 10/13/2022, 10:32:19 PM
     **/
    @Trace(operationName = "M3-生成语义内容")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public GenerateTargetCycleNameRespDto generateTargetCycleName(GenerateTargetCycleNameReqDto reqDto) {
        //{cycleStandardName}{targetContentName}
        boolean bRetFlag = false;
        GenerateTargetCycleNameRespDto retData = new GenerateTargetCycleNameRespDto();
        String retConent = "";
        QuerySemanticEngineDetailReqDto querySemanticEngineDetailReqDto = new QuerySemanticEngineDetailReqDto();
        querySemanticEngineDetailReqDto.setTemplateSemanticEngineCode("GENERATE_TARGET_CYCLE_NAME");
        QuerySemanticEngineDetailRespDto querySemanticEngineDetailRespDto = fwCompTemplateEngineClient.querySemanticEngineDetail(querySemanticEngineDetailReqDto).getData();
        if (querySemanticEngineDetailRespDto != null && querySemanticEngineDetailRespDto.getTemplateEngineTemplate() != null) {
            String cycleStandardName = "\\{cycleStandardName}";
            String targetContentName = "\\{targetContentName}";
            if (reqDto.getCycleStandardName() != null && !reqDto.getCycleStandardName().isEmpty()
                    && reqDto.getTargetContentName() != null && !reqDto.getTargetContentName().isEmpty()) {
                bRetFlag = true;
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(cycleStandardName, reqDto.getCycleStandardName());
                retConent = retConent.replaceAll(targetContentName, reqDto.getTargetContentName());
            } else {
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(cycleStandardName, "---");
            }

            if (retConent != null && !retConent.isEmpty()) {
                retConent = retConent.replaceAll("---", "");
                retConent = retConent.replaceAll("（）", "");
                retData.setObjectName(retConent);
            }

            if (bRetFlag) {
                return retData;
            }

        }
        return retData;
    }

    /**
     * code:calcSpecExecCycleList
     * name:M3-执行特殊执行周期分析（计算出特殊执行周期列表）
     * desc:undefined
     * gen by moon at 10/18/2022, 2:19:22 AM
     **/
    @Trace(operationName = "M3-执行特殊执行周期分析（计算出特殊执行周期列表）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSpecExecCycleStageAnaRespDto implementSpecExecCycleStageAna(ImplementSpecExecCycleStageAnaReqDto reqDto) {
        ImplementSpecExecCycleStageAnaRespDto retData = new ImplementSpecExecCycleStageAnaRespDto();
        if (reqDto.getSubCycleList() == null || reqDto.getSubCycleList().isEmpty() || reqDto.getExecuteCycleStageList() == null || reqDto.getExecuteCycleStageList().isEmpty()) {
            return retData;
        }
        //收集所有关键时间点
        SubCycleDto head = null;
        SubCycleDto tail = null;
        Map<Date, List<SubCycleDto>> index = new LinkedHashMap<>();
        SubCycleDto lastElm = null;
        int start = 0;
        for (SubCycleDto oneCycle : reqDto.getSubCycleList()) {
            if (start == 0) {
                head = oneCycle;
                start = 1;
            }
            List<SubCycleDto> cycleList = new ArrayList<>();
            if (lastElm == null) {
                cycleList.add(oneCycle);
            } else {
                cycleList.add(lastElm);
                cycleList.add(oneCycle);
            }
            index.put(oneCycle.getCycleStartTime(), cycleList);
            lastElm = oneCycle;
        }
        SubCycleDto lastCycle = reqDto.getSubCycleList().get(reqDto.getSubCycleList().size() - 1);
        tail = lastCycle;
        List<SubCycleDto> cycleList = new ArrayList<>();
        cycleList.add(lastCycle);
        index.put(lastCycle.getCycleEndTime(), cycleList);

        //投篮子
        for (Map.Entry<Date, List<SubCycleDto>> one : index.entrySet()) {
            for (ExecuteCycleStageDto subOne : reqDto.getExecuteCycleStageList()) {
                if (one.getKey().getTime() > subOne.getCycleStartTime().getTime()
                        && one.getKey().getTime() < subOne.getCycleEndTime().getTime()) {
                    SpecExecCycleStageAnaDto elm = new SpecExecCycleStageAnaDto();
                    retData.getSpecExecCycleStageAnaList().add(elm);
                    BeanUtil.copyProperties(subOne, elm);
                    if (one.getValue().size() > 1) {


                        elm.setLastSubEvaObjTargetCycleId(one.getValue().get(0).getEvaObjTargetCycleId());
                        elm.setLastSubCycleId(one.getValue().get(0).getCycleId());

                        //保持原来的开始时间
                        elm.setLastExeCycleStartTime(subOne.getCycleStartTime());
                        //校准为下个周期的开始时间
                        elm.setLastExeCycleEndTime(one.getValue().get(1).getCycleStartTime());

                        elm.setLastSubCycleStartTime(one.getValue().get(0).getCycleStartTime());
                        elm.setLastSubCycleEndTime(one.getValue().get(0).getCycleEndTime());

                        elm.setNextSubEvaObjTargetCycleId(one.getValue().get(1).getEvaObjTargetCycleId());
                        elm.setNextSubCycleId(one.getValue().get(1).getCycleId());

                        //校准为上个周期的结束时间
                        elm.setNextExeCycleStartTime(one.getValue().get(0).getCycleEndTime());
                        //保持原来的开始时间
                        elm.setNextExeCycleEndTime(subOne.getCycleEndTime());

                        elm.setNextSubCycleStartTime(one.getValue().get(1).getCycleStartTime());
                        elm.setNextSubCycleEndTime(one.getValue().get(1).getCycleEndTime());

                    } else {
                        if (head.getCycleStartTime().getTime() > subOne.getCycleStartTime().getTime()
                                && head.getCycleStartTime().getTime() < subOne.getCycleEndTime().getTime()) {

                            elm.setNextSubEvaObjTargetCycleId(one.getValue().get(0).getEvaObjTargetCycleId());
                            elm.setNextSubCycleId(one.getValue().get(0).getCycleId());

                            //校准为上个周期的结束时间
                            elm.setNextExeCycleStartTime(one.getValue().get(0).getCycleStartTime());
                            //保持原来的开始时间
                            elm.setNextExeCycleEndTime(subOne.getCycleEndTime());

                            elm.setNextSubCycleStartTime(one.getValue().get(0).getCycleStartTime());
                            elm.setNextSubCycleEndTime(one.getValue().get(0).getCycleEndTime());
                        } else if (tail.getCycleEndTime().getTime() > subOne.getCycleStartTime().getTime()
                                && tail.getCycleEndTime().getTime() < subOne.getCycleEndTime().getTime()) {
                            elm.setLastSubEvaObjTargetCycleId(one.getValue().get(0).getEvaObjTargetCycleId());
                            elm.setLastSubCycleId(one.getValue().get(0).getCycleId());

                            //保持原来的开始时间
                            elm.setLastExeCycleStartTime(subOne.getCycleStartTime());
                            //校准为下个周期的开始时间
                            elm.setLastExeCycleEndTime(one.getValue().get(0).getCycleEndTime());

                            elm.setLastSubCycleStartTime(one.getValue().get(0).getCycleStartTime());
                            elm.setLastSubCycleEndTime(one.getValue().get(0).getCycleEndTime());
                        }
                    }
                    break;
                }
            }
        }

        return retData;
    }

    /**
     * code:specCycleAnalyse
     * name:M3-执行特殊周期分析（查询与父周期开始时间、结束时间相交的周期列表）
     * desc:undefined
     * gen by moon at 10/18/2022, 5:51:10 AM
     **/
    @Trace(operationName = "M3-执行特殊周期分析（查询与父周期开始时间、结束时间相交的周期列表）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSpecCycleAnaRespDto implementSpecCycleAna(ImplementSpecCycleAnaReqDto reqDto) {
        ImplementSpecCycleAnaRespDto retData = new ImplementSpecCycleAnaRespDto();
        for (CycleDto oneCycle : reqDto.getCycleList()) {

            if (reqDto.getCycleStartTime() != null) {
                if (reqDto.getCycleStartTime().getTime() >= oneCycle.getCycleStartTime().getTime() && reqDto.getCycleStartTime().getTime() <= oneCycle.getCycleEndTime().getTime()) {
                    retData.getCycleList().add(oneCycle);
                }
            }

            if (reqDto.getCycleEndTime() != null) {
                if (reqDto.getCycleEndTime().getTime() >= oneCycle.getCycleStartTime().getTime() && reqDto.getCycleEndTime().getTime() <= oneCycle.getCycleEndTime().getTime()) {
                    retData.getCycleList().add(oneCycle);
                }
            }
        }
        return retData;
    }

    /**
     * code:collectionsMergeData
     * name:M3-执行周期列表融合（合并模版下启用的周期类型及特殊周期类型所对应周期列表）
     * desc:undefined
     * gen by moon at 10/18/2022, 5:51:29 AM
     **/
    @Trace(operationName = "M3-执行周期列表融合（合并模版下启用的周期类型及特殊周期类型所对应周期列表）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementMergeCycleListRespDto implementMergeCycleList(ImplementMergeCycleListReqDto reqDto) {
        ImplementMergeCycleListRespDto retData = new ImplementMergeCycleListRespDto();
        for (SpecCycleDto one : reqDto.getSpecCycleList()) {
            MergeCycleDto elm = new MergeCycleDto();
            BeanUtil.copyProperties(one, elm);
            retData.getMergeCycleList().add(elm);
        }

        for (TemplateCycleDto one : reqDto.getTemplateCycleList()) {
            MergeCycleDto elm = new MergeCycleDto();
            BeanUtil.copyProperties(one, elm);
            retData.getMergeCycleList().add(elm);
        }
        return retData;
    }

    /**
     * code:collectionsIntersectionsData
     * name:M3-获取数据集交集（模版启用的周期类型与平台开通的特殊周期类型交集）
     * desc:undefined
     * gen by moon at 10/20/2022, 11:59:25 AM
     **/
    @Trace(operationName = "M3-获取数据集交集（模版启用的周期类型与平台开通的特殊周期类型交集）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainCollectionsIntersectionsDataRespDto obtainCollectionsIntersectionsData(ObtainCollectionsIntersectionsDataReqDto reqDto) {
        ObtainCollectionsIntersectionsDataRespDto retData = new ObtainCollectionsIntersectionsDataRespDto();
        for (String one : reqDto.getCollectionsIntersectionsDataAList()) {
            if (reqDto.getCollectionsIntersectionsDataBList().contains(one)) {
                retData.getCycleTypeList().add(one);
            }
        }
        return retData;
    }

    /**
     * code:objectToData
     * name:M3-执行单条融合周期列表（特殊方法）
     * desc:undefined
     * gen by moon at 10/22/2022, 11:40:56 PM
     **/
    @Trace(operationName = "M3-执行单条融合周期列表（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementMergeSingleCycleListRespDto implementMergeSingleCycleList(ImplementMergeSingleCycleListReqDto reqDto) {
        ImplementMergeSingleCycleListRespDto retData = new ImplementMergeSingleCycleListRespDto();
        if (reqDto.getCycleIdA() != null) {
            CycleDto elmA = new CycleDto();
            elmA.setCycleId(reqDto.getCycleIdA());
            elmA.setCycleStandardName(reqDto.getCycleStandardNameA());
            elmA.setCycleStartTime(reqDto.getCycleStartTimeA());
            elmA.setCycleEndTime(reqDto.getCycleEndTimeA());
            elmA.setCycleTypeCode(reqDto.getCycleTypeCodeA());
            elmA.setOrderNumber(reqDto.getOrderNumberA());
            retData.getCycleList().add(elmA);
        }

        if (reqDto.getCycleIdB() != null) {
            CycleDto elmB = new CycleDto();
            elmB.setCycleId(reqDto.getCycleIdB());
            elmB.setCycleStandardName(reqDto.getCycleStandardNameB());
            elmB.setCycleStartTime(reqDto.getCycleStartTimeB());
            elmB.setCycleEndTime(reqDto.getCycleEndTimeB());
            elmB.setCycleTypeCode(reqDto.getCycleTypeCodeB());
            elmB.setOrderNumber(reqDto.getOrderNumberB());
            retData.getCycleList().add(elmB);
        }


        return retData;
    }

    /**
     * code:createSpecCycleName
     * name:M3执行特殊周期重新排序命名（特殊方法）
     * desc:undefined
     * gen by moon at 10/22/2022, 11:42:07 PM
     **/
    @Trace(operationName = "M3执行特殊周期重新排序命名（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSpecialCycleSortNameRespDto implementSpecialCycleSortName(ImplementSpecialCycleSortNameReqDto reqDto) {
        ImplementSpecialCycleSortNameRespDto retData = new ImplementSpecialCycleSortNameRespDto();
        Long count = 1L;
        for (String one : reqDto.getExecuteCycleStageList()) {
            String cycelName = "第" + count + reqDto.getCycleTypeName();
            ExecuteCycleStageDto elm = new ExecuteCycleStageDto();
            elm.setExecuteCycleStageId(one);
            elm.setCycleStandardName(cycelName);
            retData.getExecuteCycleStageList().add(elm);
            count++;
        }
        return retData;
    }

    /**
     * code:getCollectionsDiff
     * name:M3-获取数据集差集（全部过程周期-子周期下的过程周期）
     * desc:undefined
     * gen by moon at 11/20/2022, 12:23:48 AM
     **/
    @Trace(operationName = "M3-获取数据集差集（全部过程周期-子周期下的过程周期）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainCollectionsDiffComRespDto obtainCollectionsDiffCom(ObtainCollectionsDiffComReqDto reqDto) {
        ObtainCollectionsDiffComRespDto retData = new ObtainCollectionsDiffComRespDto();
        reqDto.getCollectionsDiffComFatList().removeAll(reqDto.getCollectionsDiffComSubList());
        retData.setCollectionsDiffList(reqDto.getCollectionsDiffComFatList());
        return retData;
    }

    /**
     * code:receptionService
     * name:M3更新被评对象目标周期【循环开始】
     * desc:undefined
     * gen by moon at 11/20/2022, 12:34:04 AM
     **/
    @Trace(operationName = "M3更新被评对象目标周期【循环开始】")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public RefreshEvaObjTargetCycleStartRespDto refreshEvaObjTargetCycleStart(RefreshEvaObjTargetCycleStartReqDto reqDto) {
        // TODO ruizhe skai dong ; 11/20/2022, 12:34:04 AM
        return new RefreshEvaObjTargetCycleStartRespDto();
    }

    /**
     * code:calcTime
     * name:M3-执行时间计算（特殊方法）
     * desc:undefined
     * gen by moon at 11/23/2022, 9:43:53 PM
     **/
    @Trace(operationName = "M3-执行时间计算（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementCalcTimeRespDto implementCalcTime(ImplementCalcTimeReqDto reqDto) {
        ImplementCalcTimeRespDto retData = new ImplementCalcTimeRespDto();

        Long sec = 0L;

        if (reqDto.getTimeUnitType() == null) {
            return retData;
        }

        if (reqDto.getTimeUnitType().equals("DAY")) {
            sec = reqDto.getAcount() * 24 * 3600;
        } else if (reqDto.getTimeUnitType().equals("HOUR")) {
            sec = reqDto.getAcount() * 3600;
        } else if (reqDto.getTimeUnitType().equals("MINUTES")) {
            sec = reqDto.getAcount() * 60;
        } else if (reqDto.getTimeUnitType().equals("SECOND")) {
            sec = reqDto.getAcount();
        }

        Date tmpDate = new Date();

        if (reqDto.getCalcFormula().equals("ADDITION_OF_TWO_NUM")) {
            tmpDate = CommonFunctionHelper.addDateBySec(reqDto.getCaluStartTime(), sec.intValue());
        } else if (reqDto.getCalcFormula().equals("SUBTRACTION_OF_TWO_NUM")) {
            tmpDate = CommonFunctionHelper.addDateBySec(reqDto.getCaluStartTime(), 0 - sec.intValue());
        }

        retData.setCalcTimeResult(tmpDate);
        return retData;
    }

    /**
     * code:collectionsIntersectionsData
     * name:M3执行取与变更字段列表交集结果（特殊方法）
     * desc:undefined
     * gen by moon at 12/6/2022, 7:16:29 PM
     **/
    @Trace(operationName = "M3执行取与变更字段列表交集结果（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementTakeChangeColumnOverlapRespDto implementTakeChangeColumnOverlap(ImplementTakeChangeColumnOverlapReqDto reqDto) {
        ImplementTakeChangeColumnOverlapRespDto retData = new ImplementTakeChangeColumnOverlapRespDto();
        List<ChangeColumnDto> filteredList = new ArrayList<>();
        Map<String, EvaObjTargetCycleWeightDto> retIndex = new HashMap<>();

        for (ChangeColumnDto one : reqDto.getChangeColumnList()) {
            if (reqDto.getBizAppChangeColList().contains(one.getEntityId())) {
                filteredList.add(one);
                if (!retIndex.containsKey(one.getEntityId())) {
                    EvaObjTargetCycleWeightDto elm = new EvaObjTargetCycleWeightDto();
                    elm.setObjTargetCycleWeightSetId(one.getEntityId());
                    retData.getEvaObjTargetCycleWeightList().add(elm);
                    retIndex.put(one.getEntityId(), elm);
                }
            }
        }


        for (ChangeColumnDto change : filteredList) {
            EvaObjTargetCycleWeightDto elm = retIndex.get(change.getEntityId());
            Field[] declaredFields = elm.getClass().getDeclaredFields();
            Map<String, Field> fieldIndex = new HashMap<>();
            for (Field field : declaredFields) {
                fieldIndex.put(field.getName(), field);
            }
            if (ObjectUtils.isNotEmpty(elm)) {
                Field fileObj = fieldIndex.get(change.getObjectPropertyCode());
                if (fileObj != null) {
                    fileObj.setAccessible(true);
                    try {
                        if (fileObj.getType().equals(Double.class)) {
                            fileObj.set(elm, Double.valueOf(change.getMetaDataColumnContent()));
                        } else if (fileObj.getType().equals(Long.class)) {
                            fileObj.set(elm, Long.valueOf(change.getMetaDataColumnContent()));
                        } else {
                            fileObj.set(elm, change.getMetaDataColumnContent());
                        }

                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }


        }


        return retData;
    }

    /**
     * code:receptionService
     * name:M3执行获取出入参业务字段（特殊方法）
     * desc:undefined
     * gen by moon at 2/8/2023, 2:11:48 PM
     **/
    @Trace(operationName = "M3执行获取出入参业务字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAccessParameterBizFieldRespDto implementAccessParameterBizField(ImplementAccessParameterBizFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAccessParameterBizFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:约定出参：执行周期阶段列表
     * desc:undefined
     * gen by moon at 5/7/2023, 10:28:08 PM
     **/
    @Trace(operationName = "约定出参：执行周期阶段列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public CalculateAcceptAboveFieldsRespDto calculateAcceptAboveFields(CalculateAcceptAboveFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, CalculateAcceptAboveFieldsRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3约定：开启自定义汇报
     * desc:undefined
     * gen by moon at 5/21/2023, 6:45:11 PM
     **/
    @Trace(operationName = "M3约定：开启自定义汇报")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldRespDto implementAcceptField(ImplementAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:出参字段：是否开启主观评分
     * desc:undefined
     * gen by moon at 2/27/2024, 2:48:31 PM
     **/
    @Trace(operationName = "出参字段：是否开启主观评分")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementFiveReceivingFieldRespDto implementFiveReceivingField(ImplementFiveReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementFiveReceivingFieldRespDto.class);

    }

    /**
     * code:receptionService
     * name:M3-接收字段：周期信息
     * desc:undefined
     * gen by moon at 9/27/2024, 9:56:10 PM
     **/
    @Trace(operationName = "M3-接收字段：周期信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementEightReceivingFieldRespDto implementEightReceivingField(ImplementEightReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementEightReceivingFieldRespDto.class);
    }
}